package com.nuoniu.sibanyun.mapper.baseMapper;

import com.nuoniu.sibanyun.entity.bo.TreeUpdateBo;
import com.nuoniu.sibanyun.entity.dto.DictDataSaveDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface TreeBaseMapper {

    void updateTreeLeaf(@Param("tableName")String tableName,@Param("id") Integer id);

    @Select("SELECT parent_id FROM ${tableName} WHERE id = #{id}")
    Integer findParentId(@Param("tableName")String tableName,@Param("id") Integer id);

    @Update("UPDATE ${tableName} set tree_leaf = #{state} WHERE id = #{id}")
    void updateTreeLeafByState(@Param("tableName")String tableName,@Param("id") Integer id,@Param("state") Integer state);

    /**
     * 更新 子集的树结构
     * @param tableName
     * @param oldParentTreeBo
     * @param newParentTreeBo
     * @param parentId
     */
    void updateChildrenTree(@Param("tableName")String tableName,@Param("old")TreeUpdateBo oldParentTreeBo,@Param("new")TreeUpdateBo newParentTreeBo,@Param("levelDiff") Integer levelDiff,@Param("parentId") Integer parentId);
}
